const sass = require('node-sass');
const loadGruntTasks = require('load-grunt-tasks')
const del = require('del');


module.exports = grunt => {
  grunt.initConfig({
    sass: {
      options: {
        sourceMap: true,
        implementation: sass
      },
      dist: {
        files: {
           'temp/assets/styles/main.scss' : 'src/assets/styles/main.scss'
        }
      }
    },
    babel: {
      options: {
        sourceMap: true,
        presets: ['@babel/preset-env']
      },
      main: {
        files: {
            'temp/assets/scripts/main.js': 'src/assets/scripts/main.js'
        }
      }
    },
    watch: {
      js: {
        files: ['src/js/*.js'],
        tasks: ['babel']
      },
      css: {
        files: ['src/scss/*.scss'],
        tasks: ['sass']
      }
    }
  })


  loadGruntTasks(grunt)

  
  grunt.registerTask('compile', ['sass', 'babel'])

  grunt.registerTask('clean', () => {
    return del(['temp/', 'dest/']);
  })
}